package practice;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}

public class Practice12 {
    /**
     * 删除公共字符
     * @param args
     * @throws IOException
     */
    public static void main1(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String t = br.readLine();
        boolean[] hash = new boolean[300];
        for (int i = 0; i < t.length(); i++) {
            hash[t.charAt(i)] = true;
        }

        for (int i = 0; i < s.length(); i++) {
            if (!hash[s.charAt(i)]) {
                System.out.print(s.charAt(i));
            }
        }
    }

    /**
     * 两个链表的第一个公共节点
     * @param pHead1
     * @param pHead2
     * @return
     */
    public ListNode FindFirstCommonNode(ListNode pHead1, ListNode pHead2) {
        ListNode cur1 = pHead1, cur2 = pHead2;
        while (cur1 != cur2) {
            cur1 = cur1 != null ? cur1.next : pHead2;
            cur2 = cur2 != null ? cur2.next : pHead1;
        }
        return cur1;
    }

    /**
     * mari和shiny
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        char[] str = in.next().toCharArray();
        long s = 0, h = 0, y = 0;
        for (int i = 0; i < n; i++) {
            char ch = str[i];
            if (ch == 's') s += 1;
            else if (ch == 'h') h += s;
            else if (ch == 'y') y += h;
        }
        System.out.println(y);
    }
}
